package practice.chapter03.stream;

import practice.chapter03.stream.interfaces.BufferedReaderMethods;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 练习从控制台输入
 */
public class TestBufferedReader implements BufferedReaderMethods {
    public static void main(String[] args) throws IOException {
        TestBufferedReader test = new TestBufferedReader();
//        test.testRead();
        test.testReadLine();


    }

    @Override
    public void testRead() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("输入字符，按q退出：");
        char c = ' ';
        while ('q' != c){
            c = (char) br.read();
            System.out.println(c);
        }

    }

    @Override
    public void testReadLine() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        System.out.println("输入字符串");
        while (!"end".equals(str)){
            str = br.readLine();
            System.out.println(str);
        }
    }
}
